﻿//=============================================================
// Copyright (C) 2011 深圳市中旭企业管理股份有限公司
// 作 者：孙德响
// 日 期：2011-11-10
// 描 述: 心得点评管理业务处理类
//
// 版 本：1.00
// 修改历史纪录
// 版 本  修改时间      修改人            修改内容
// 1.00   2011/11/10    孙德响           
//=============================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ZX.TR.Library;
using ZX.Common;
namespace ZX.TR.Bussiness
{
    /// <summary>
    /// 心得点评管理业务处理类
    /// </summary>
    public class BTrActivityCourse:BLL.Extend.BaseBussnies
    {
       
        /// <summary>
        /// 更新信息
        /// </summary>
        /// <param name="type"> if  type==1  then 心得更新    else if type==2 点评更新</param>
        /// <returns></returns>
        public bool UpdateTrActivityCourse(TrActivityCourse acourse, int type)
        {
            this.entity = new TrActivityCourse();
            ZX.SPL.Factory.DialectFactory DF = ZX.SPL.Factory.Dialects.GetDialect(entity);
            if (type == 1)
            {
                return DF.Update("CourseShare='" + acourse.CourseShare + "',ShareUserid='" + acourse.ShareUserid.ToString() + "',ShareTime='" + acourse.ShareTime.ToString() + "'", "TrActivityCourseID='" + acourse .TrActivityCourseID.ToString()+ "'");
            }
            else
            {
                return DF.Update("CourseReview='" + acourse.CourseReview + "',ReviewUserid='" + acourse.ReviewUserid.ToString() + "',ReviewTime='" + acourse.ShareTime.ToString() + "'", "TrActivityCourseID='" + acourse.TrActivityCourseID.ToString() + "'");
            }
        }
        /// <summary>
        /// 根据ID获取计划相关信息
        /// </summary>
        /// <param name="IndagateID">调研ID</param>
        /// <returns>实体对象</returns>
        public V_CourseSum GetCourseByCoursID(Guid courseID)
        {
            this.entity = new V_CourseSum();
            return this.GetEntityBySqlComm("select * from V_CourseSum where TrActivityCourseID='" + CSVHelper.FmSQL(courseID) + "'") as V_CourseSum;
        }
        /// <summary>
        /// 依据用户ID获取课程，开始时间
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        public IList<V_TrActivityCourse> getTrACourseList(int tn,string gd)
        {
            this.entity = new V_TrActivityCourse();
            return this.GetEntitysBySqlComm<V_TrActivityCourse>("select top " + CSVHelper.FmSQL(tn) + " TrCourseID,CourseName,planstarttime from dbo.V_TrActivityCourse where stuName like '%" + CSVHelper.FmLikeSQL(gd) + "%' and  planstarttime between getdate() and getdate()+2 order by planstarttime");
        }

        /// <summary>
        /// 依据ID获取心得信息
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        public V_TrActivityCourseX GetVTrActivityCourseIfon(string guid)
        {
            this.entity=new V_TrActivityCourseX();
            return (V_TrActivityCourseX)this.GetEntityById(guid);
        }
        /// <summary>
        /// 依据ID获取心得信息
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        public TrActivityCourse GetTrActivityCourseIfon(string guid)
        {
            this.entity = new TrActivityCourse();
            return (TrActivityCourse)this.GetEntityById(guid);
        }

       

    }
}
